<script>
export default {
    props: {
        row: {},
        currName: "",
        isAudit: false
    },
    render: function (h, ctx) {
        const _this = this;
        let actionsArr = [
            { label: '提交', type: 'text', size: 'mini', icon: 'el-icon-check', fn: _this.onPublish, show: _this.row.currentStatus == '1' },
            { label: '编辑', type: 'text', size: 'mini', icon: 'el-icon-edit', fn: _this.onEdit, show: _this.row.currentStatus == '1' },
            { label: '删除', type: 'text', size: 'mini', icon: 'el-icon-delete', fn: _this.onDelete, show: _this.row.currentStatus == '1' },
            { label: '详情', type: 'text', size: 'mini', icon: 'el-icon-view', fn: _this.onDetail, show: true },
        ];
        if (this.isAudit) {
            actionsArr = [
                // { label: '审核', type: 'text', size: 'mini', icon: 'el-icon-document-checked', fn: _this.onPublish, show: _this.row.currentStatus == 4 && _this.row.assigneeId == this.currName},
                // { label: '发布', type: 'text', size: 'mini', icon: 'el-icon-share', fn: _this.onPublish, show: (_this.row.currentStatus == 2 || _this.row.currentStatus == 3) && (_this.row.assigneeId == this.currName)},
                // { label: '审核', type: 'text', size: 'mini', icon: 'el-icon-document-checked', fn: _this.onAudit, show: (_this.row.currentStatus == 2 || _this.row.currentStatus == 3) && _this.row.assigneeId == this.currName },
                // { label: '发布', type: 'text', size: 'mini', icon: 'el-icon-share', fn: _this.onAudit, show: _this.row.currentStatus == 4 && _this.row.assigneeId == this.currName },
                // { label: '下架', type: 'text', size: 'mini', icon: 'el-icon-circle-close', fn: _this.onAudit, show: _this.row.currentStatus == 5 && _this.row.assigneeId == this.currName },
                { label: '审核', type: 'text', size: 'mini', icon: 'el-icon-document-checked', fn: _this.onAudit, show: (_this.row.currentStatus == 2 || _this.row.currentStatus == 3)},
                { label: '发布', type: 'text', size: 'mini', icon: 'el-icon-share', fn: _this.onAudit, show: _this.row.currentStatus == 4},
                { label: '下架', type: 'text', size: 'mini', icon: 'el-icon-circle-close', fn: _this.onAudit, show: _this.row.currentStatus == 5 },
                // { label: '审核', type: 'primary', fn: _this.onAudit, show: true },
                // { label: '撤销', type: 'primary', fn: _this.onAudit, show: true },
                { label: '详情', type: 'text', size: 'mini', icon: 'el-icon-view', fn: _this.onDetail, show: true },
            ];
        }
        return (<span>{(actionsArr.map(s => {
            if (!s.show) {
                return <span></span>
            }
            return <el-button style="margin: 0 2px;" size={s.size} type={s.type} icon={s.icon}
                onClick={s.fn} >{s.label}</el-button >
        }))}</span>)
    },
    methods: {
        onPublish() {
            this.$emit('onPublish', this.row.id);
        },
        onOffShelf() {
            this.$emit('onOffShelf', this.row.id);
        },
        onEdit() {
            this.$emit('onEdit', this.row.id);
        },
        onDetail() {
            this.$emit('onDetail', this.row.id);
        },
        onDelete() {
            this.$emit('onDelete', this.row.id);
        },
        onAudit() {
            this.$emit('onAudit', this.row);
        }
    }
};
</script>
